package com.zzy.studentsignin.controller;

import com.zzy.studentsignin.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 邹靓仔
 * @date 2020/4/25 -16:30 -student-signin
 **/
@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/not")
    public Map<String ,Object> findAll(){
        Map<String ,Object> result = new HashMap<>();
        result.put("code", userService.findAll());
        return result;
    }
    @GetMapping("/already")
    public Map<String ,Object>  findAllYI(){
        Map<String ,Object> result = new HashMap<>();
        result.put("code", userService.findAllyes());
        return result;
    }
    @PostMapping("/upload")
    public String upload(String classes, MultipartFile nameListExcel){
        //接收到前台传过来的文件对象，交给service层或者Excel工具类来解析数据
        //System.out.println("接收前台表单提交数据："+classes+nameListExcel);
        String result = userService.upload(classes,nameListExcel);
        return result;
    }

}
